package GUI;


import java.util.ArrayList;

import javax.swing.JButton;

import Algorithms.Context;
import Algorithms.LDepthStrategy;
import Cani.CautareInAdancimeLimitata;
import Cani.Nod;
import Joc.Joc;
import Joc.JocStates;
import Operators.FarmerOperators;
import States.FarmerStates;
import Templates.Operator;
import Templates.State;

public class AdancimeLimitataCommand extends JButton implements Command{

	private static final long serialVersionUID = 1L;
	
	public AdancimeLimitataCommand(){
		super("Algoritm Adancime Limitata");
	}
	
	public void execute(){
		SimulareDesenPanel.clearDesen();
		Joc j=Joc.getJocinstance();
		if(j.getState()==JocStates.CANI){
			CautareInAdancimeLimitata c = new CautareInAdancimeLimitata();
			Nod n = new Nod(0, 0, 0, "expandabil");
			c.Initializare(n);
			c.rezolvare(n);
			c.afisareeee();
			MassagePanel.writeMessagePanel("S-a aplicat algoritmul Adancime Limitata!" );
		}
		else if(j.getState()==JocStates.LCV){
			ArrayList<Operator<FarmerStates>> farmerOperators=FarmerOperators.returnOperators();
			State<FarmerStates> FarmerInitialState=FarmerStates.initalState();
			ArrayList<State<FarmerStates>> FarmerFinalState=FarmerStates.finalStates();
			String FarmerLDepth="FarmerLDepth.txt";
			Context<FarmerStates> f=new Context<FarmerStates>(new LDepthStrategy<FarmerStates>());
			f.executeStrategy(FarmerInitialState,FarmerFinalState,farmerOperators,FarmerLDepth);
			MassagePanel.writeMessagePanel("S-a aplicat algoritmul Adancime Limitata!" );
		}
		else if (j.getState() == JocStates.PUZZLE) {
			MassagePanel.writeMessagePanel("NU poate fi aplicat algoritmul Adancime Limitata!" );
		}
		
	}

}
